#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt
import tools

(X, Y) = tools.oneSamples()
th = np.matrix([[0], [0]])

(theta, J, ci) = tools.gradientDescent(th, X, Y, alpha=2)
plt.plot(J)
plt.savefig('a-2-J.png')
plt.close()

(theta, J, ci) = tools.gradientDescent(th, X, Y, alpha=0.1)
plt.plot(J, label='a=0.1')
plt.legend()

(theta, J, ci) = tools.gradientDescent(th, X, Y, alpha=0.01)
plt.plot(J, label='a=0.01')
plt.legend()

(theta, J, ci) = tools.gradientDescent(th, X, Y, alpha=0.001)
plt.plot(J, label='a=0.001')
plt.legend()
plt.savefig('a-0.1-0.0001-J.png')
